void sortColors(int* nums, int numsSize)
{
    int i = 0;
    int p0 = 0;
    int p2 = numsSize - 1;
    if (numsSize <= 1)
        return;
    for (; i <= p2; i++)
    {
        while (nums[i] == 2 && p2 > i)
        {
            int tmp = nums[i];
            nums[i] = nums[p2];
            nums[p2--] = tmp;
        }
        if (nums[i] == 0)
        {
            int tmp = nums[i];
            nums[i] = nums[p0];
            nums[p0++] = tmp;
        }
    }
}
#include<stdlib.h>
void quickly_sort(int* arr, int begin, int end)
{
   
    if (end <= begin)
        return;
    int mid = begin + rand() %  (end - begin + 1);
    int tmp = arr[mid];
    arr[mid] = arr[begin];
    arr[begin] = tmp;
    int hole = arr[begin];
    int left  = begin;
    int right = end;
    while (right > left)
    {
        while (right > left && arr[right] <= hole)
            --right;
        arr[left] = arr[right];
        while (left < right && arr[left] >= hole)
            ++left;
        arr[right] = arr[left];
    }
    arr[left] = hole;
    quickly_sort(arr, begin, left - 1);
    quickly_sort(arr, left + 1, end);
}

int findKthLargest(int* nums, int numsSize, int k)
{
    srand(0);
    quickly_sort(nums, 0, numsSize - 1);
    int i = 0;
    return nums[k - 1];
}



/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* numbers, int numbersSize, int target, int* returnSize) 
{
    int* nums = (int*)malloc(2 * sizeof(int));
    int left = 0;
    *returnSize = 2;
    int right = numbersSize - 1;
    while (left < right)
    {

        while (numbers[right] + numbers[left] > target)
            right--;
        while (numbers[right] + numbers[left] < target)
            left++;
        if (numbers[left] + numbers[right] == target)
            break;
    }
    nums[0] = left+1;
    nums[1] = right + 1;
    return nums;
}

#include<string.h>
#include<ctype.h>
#include<stdbool.h>
bool my_isalpha(int c)
{
    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')||(c>='0'&&c<='9'))
        return 1;
    else
        return 0;
}

bool isPalindrome(char* s)
{
    int left = -1;
    int right = strlen(s);
    int flag = 1;
    while ( ++left < --right )
    {
        while (!my_isalpha(s[left])&&left<right)
            left++;
        while (!my_isalpha(s[right])&&left<right)
            right--;
        char a = tolower(s[left]);
        char b = tolower(s[right]);
        if (a != b)
        {
            flag = 0;
            break;
        }
            
    }
    return flag;
}

int main()
{
    char num[] = "A man, a plan, a canal: Panama";
    isPalindrome(num);
    return;
}